package edu.scau.pos215.domain;

import edu.scau.pos215.core.domain.BaseEntity;

import java.io.Serializable;
import java.math.BigDecimal;


public class SaleItem extends BaseEntity {
    // 主键
    private Long saleItemId;
    // 产品
    private ProductDescription productDescription;
    // 数量
    private int quantity;
    //订单ID
    private Long saleId;
    //产品ID
    private Long productId;
    //价格
    private BigDecimal price;
    //状态
    private  String status;
    //删除标记
    private String delFlag;

    public SaleItem() {
    }

    public SaleItem(Long saleItemId, ProductDescription productDescription, int quantity, Long saleId, Long productId, BigDecimal price, String status, String delFlag) {
        this.saleItemId = saleItemId;
        this.productDescription = productDescription;
        this.quantity = quantity;
        this.saleId = saleId;
        this.productId = productId;
        this.price = price;
        this.status = status;
        this.delFlag = delFlag;
    }

    public Long getSaleId() {
        return saleId;
    }

    public void setSaleId(Long saleId) {
        this.saleId = saleId;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public Long getSaleItemId() {
        return saleItemId;
    }

    public void setSaleItemId(Long saleItemId) {
        this.saleItemId = saleItemId;
    }

    public ProductDescription getProductDescription() {
        return productDescription;
    }

    public void setProductDescription(ProductDescription productDescription) {
        this.productDescription = productDescription;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /**
     * 计算小计
     * @return 小计
     */
    public BigDecimal getSubTotal(){
        BigDecimal subTotal =  productDescription.getPrice().multiply(new BigDecimal(quantity));
        return subTotal;
    }

    @Override
    public String toString() {
        return "SaleItem{" +
                "saleItemId=" + saleItemId +
                ", productDescription=" + productDescription +
                ", quantity=" + quantity +
                ", saleId=" + saleId +
                ", productId=" + productId +
                ", price=" + price +
                ", status='" + status + '\'' +
                ", delFlag='" + delFlag + '\'' +
                '}';
    }
}
